<template>
  <div ref="radar" class="radar-echart" />
</template>

<script>
import * as Echarts from 'echarts'
import baseData from './baseData'
export default {
  name: 'Radar',
  data() {
    return {
      echarts: null
    }
  },
  // 这个时候已经挂载好了
  mounted() {
    // 1、实例化一个echarts实例对象
    this.echarts = Echarts.init(this.$refs.radar)
    // 2、设置配置项
    this.echarts.setOption(baseData)
    // 获取请求数据
    this.initData()
  },
  methods: {
    initData() {
      setTimeout(_ => {
        const data = [{
          value: [10, 1, 100, 5, 100, 0],
          name: '张三'
        },
        {
          value: [50, 50, 50, 50, 50, 10],
          name: '李四'
        }]
        // 整理好最新的配置数据
        baseData.series[0].data = data
        this.echarts.setOption(baseData)
        // 再次绘制
      }, 2000)
    }
  }
}
</script>

<style>
.radar-echart {
    width: 600px;
    height: 400px;
}
</style>
